package com.yp.studentsys.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration//基本和@Bean  配合用
@EnableSwagger2
@EnableKnife4j//kinfe4j自身注解
@Import(BeanValidatorPluginsConfiguration.class)//导入的工具
public class Knife4jConfig {
    /**
     * Docket 的构建
     */
    @Bean
    public Docket buildDocket(){
        ApiInfo build = new ApiInfoBuilder()
                .contact(new Contact("yp","",""))
                .version("v0.1")
                .title("学员管理系统")
                .build();
        //文档类型  SWAGGER_2
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(build)
                .select()
                .apis(
                        RequestHandlerSelectors.basePackage("com.yp.studentsys.web.controller")
                //选择路径
                ).paths(PathSelectors.any())
                .build();
    }
}
